//
//  FSDockItem.m
//  cocoapodText
//
//  Created by apple on 16/8/10.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ShiPei.h"
#import "FSDockItem.h"
#import <Foundation/Foundation.h>

@implementation FSDockItem



/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor clearColor]];
        //添加子视图
        [self subView];
    }
    return self;
}

//子视图懒加载
-(void)subView{
    //选中白色背景（根据选中状态显示隐藏）
    UIImageView *menuAllBackItem=[[UIImageView alloc]initWithFrame:[ShiPei CGRectMakeScale:3.5 :5 :153 :60]];
    [menuAllBackItem setBackgroundColor:[UIColor whiteColor]];
    [menuAllBackItem.layer setMasksToBounds:YES];
    [menuAllBackItem.layer setCornerRadius:[ShiPei CGFloatMakeScale:30]];
    [self addSubview:menuAllBackItem];
    self.menuAllBackItem=menuAllBackItem;
    //选中的菜单图标
    UIImageView *menuSelectImageView=[[UIImageView alloc]initWithFrame:[ShiPei CGRectMakeScale:7.5 :10 :50 :50]];
    [self addSubview:menuSelectImageView];
    self.menuSelectImageView=menuSelectImageView;
    //未选中的菜单图标
    UIImageView *menuUnSelectImageView=[[UIImageView alloc]initWithFrame:[ShiPei CGRectMakeScale:15 :17.5 :35 :35]];
    [self addSubview:menuUnSelectImageView];
    self.menuUnSelectImageView=menuUnSelectImageView;
    //菜单名称
    UILabel *meunItemNameLabel=[[UILabel alloc]initWithFrame:[ShiPei CGRectMakeScale:61 :5 :90 :60]];
    [meunItemNameLabel setTextColor:[UIColor blackColor]];
    [meunItemNameLabel setBackgroundColor:[UIColor clearColor]];
    [meunItemNameLabel setFont:[UIFont boldSystemFontOfSize:[ShiPei CGFloatMakeFontScaleWithPX:30]]];
    [self addSubview:meunItemNameLabel];
    self.meunItemNameLabel=meunItemNameLabel;
}

//设置选中图片
-(void)setSelectedImage:(NSString *)selectedImage{
    [self.menuSelectImageView setImage:[UIImage imageNamed:selectedImage]];
}

-(void)setUnSelectedImage:(NSString *)unSelectedImage{
    [self.menuUnSelectImageView setImage:[UIImage imageNamed:unSelectedImage]];
}

-(void)setLabelText:(NSString *)labelText{
    [self.meunItemNameLabel setText:labelText];
}

-(void)setFrame:(CGRect)frame{
    //固定Item宽高
    frame.size=CGSizeMake([ShiPei CGFloatMakeScale:GPDockItemWidth], [ShiPei CGFloatMakeScale:GPDockItemHeight]);
    [super setFrame:frame];
}


@end